package work.demo;

import work.config.Constant;
import work.fram.KeyValueMapper;
import work.fram.SqlMaker;
import work.person.helper.ConditionHelper;
import work.utils.CommonExcelUtils;
import work.utils.TextUtils;

import java.io.File;
import java.util.List;
import java.util.Map;

public class OrgNameUpdate {

    public static void main(String[] args) {

        List<Map<String, String>> list = CommonExcelUtils.e2m(new File(Constant.work, "人员服务组织机构列表(1)(1)(1).xls"), "Sheet1", 0);

        SqlMaker maker = new SqlMaker("md_organization");

        KeyValueMapper mapper = maker.createKeyValueMapper();

        StringBuilder builder = new StringBuilder();

        for (Map<String, String> map : list) {

            mapper.reset();
            mapper.put("org_name",map.get("名称"));

            if (maker.make(SqlMaker.TYPE_UPDATE, ConditionHelper.create("org_code", "=", map.get("编码")))) {
                builder.append(maker.getSql()).append("\n");
            }

        }

        if (TextUtils.textToClipboard(builder.toString())) {
            System.out.println("已复制到粘贴板");
        }


    }

}
